/*
documentation of api
http://wiki.developers.facebook.com/index.php/Data_Store_API_documentation

Copyright (c) 2008 sol wu

Extension to Jason Christ's actionscript-facebook-api.  Based on Jason Christ's excellent api.  :)  

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/

package com.pbking.facebook.methodGroups
{
	import com.pbking.facebook.Facebook;
	import com.pbking.facebook.delegates.data.CreateObjectDelegate;
	import com.pbking.facebook.delegates.data.CreateObjectTypeDelegate;
	import com.pbking.facebook.delegates.data.DeleteObjectDelegate;
	import com.pbking.facebook.delegates.data.GetHashValueDelegate;
	import com.pbking.facebook.delegates.data.GetObjectDelegate;
	import com.pbking.facebook.delegates.data.GetUserPreferenceDelegate;
	import com.pbking.facebook.delegates.data.IncHashValueDelegate;
	import com.pbking.facebook.delegates.data.RemoveHashKeyDelegate;
	import com.pbking.facebook.delegates.data.RemoveHashKeysDelegate;
	import com.pbking.facebook.delegates.data.SetHashValueDelegate;
	import com.pbking.facebook.delegates.data.SetUserPreferenceDelegate;
	import com.pbking.facebook.delegates.data.UpdateObjectDelegate;
	
	public class Data
	{
		// VARIABLES //////////
		
		private var facebook:Facebook;
		
		// CONSTRUCTION //////////
		
		function Data(facebook:Facebook):void
		{
			this.facebook = facebook;
		}
		
		// FACEBOOK FUNCTION CALLS //////////
		
		// user preference api //////////
		
		/**
		 * update one preference 
		 */
		public function setUserPreference(pref_id:int, value:String, callback:Function=null):SetUserPreferenceDelegate
		{
			var delegate:SetUserPreferenceDelegate = new SetUserPreferenceDelegate(facebook, pref_id, value);
			return MethodGroupUtil.addCallback(delegate, callback) as SetUserPreferenceDelegate;
		}

		/**
		 * update multiple preferences in batch
		 */
		//public function setUserPreferences(, callback:Function=null):SetUserPreferencesDelegate
		//{
		//	
		//}
		
		/**
		 * get one preference of a user
		 */
		public function getUserPreference(pref_id:int, callback:Function=null):GetUserPreferenceDelegate
		{
			var delegate:GetUserPreferenceDelegate = new GetUserPreferenceDelegate(facebook, pref_id);
			return MethodGroupUtil.addCallback(delegate, callback) as GetUserPreferenceDelegate;
		}
		
		/**
		 * get all preferences of a user 
		 */
		//public function getUserPreferences(, callback:Function=null):GetUserPreferencesDelegate
		//{
		//	
		//}
		
		// Object Data Definition api //////////
		
		public function createObjectType(name:String, callback:Function=null):CreateObjectTypeDelegate
		{
			var delegate:CreateObjectTypeDelegate = new CreateObjectTypeDelegate(facebook, name);
			return MethodGroupUtil.addCallback(delegate, callback) as CreateObjectTypeDelegate;		
		}
		
		
		// Object Data Access api //////////
		
		
		public function createObject(objType:String, properties:Object, callback:Function=null):CreateObjectDelegate
		{
			var delegate:CreateObjectDelegate = new CreateObjectDelegate(facebook, objType, properties);
			return MethodGroupUtil.addCallback(delegate, callback) as CreateObjectDelegate;		
		}
		
		public function updateObject(objid:Number, properties:Object, replace:Boolean, callback:Function=null):UpdateObjectDelegate
		{
			var delegate:UpdateObjectDelegate = new UpdateObjectDelegate(facebook, objid, properties, replace);
			return MethodGroupUtil.addCallback(delegate, callback) as UpdateObjectDelegate;		
		}
		
		public function deleteObject(objid:Number, callback:Function=null):DeleteObjectDelegate
		{
			var delegate:DeleteObjectDelegate = new DeleteObjectDelegate(facebook, objid);
			return MethodGroupUtil.addCallback(delegate, callback) as DeleteObjectDelegate;		
		}
		
		public function getObject(objid:Number, callback:Function=null):GetObjectDelegate 
		{
			var delegate:GetObjectDelegate = new GetObjectDelegate(facebook, objid);
			return MethodGroupUtil.addCallback(delegate, callback) as GetObjectDelegate;
		}
		
		public function getHashValue(objType:String, key:String, propName:String, callback:Function=null):GetHashValueDelegate
		{
			var delegate:GetHashValueDelegate = new GetHashValueDelegate(facebook, objType, key, propName);
			return MethodGroupUtil.addCallback(delegate, callback) as GetHashValueDelegate;
		}
		
		public function setHashValue(objType:String, key:String, value:String, propName:String, callback:Function=null):SetHashValueDelegate
		{
			var delegate:SetHashValueDelegate = new SetHashValueDelegate(facebook, objType, key, value, propName);
			return MethodGroupUtil.addCallback(delegate, callback) as SetHashValueDelegate;
		}
		
		public function incHashValue(objType:String, key:String, propName:String, increment:int=1, callback:Function=null):IncHashValueDelegate
		{
			var delegate:IncHashValueDelegate = new IncHashValueDelegate(facebook, objType, key, propName, increment);
			return MethodGroupUtil.addCallback(delegate, callback) as IncHashValueDelegate;
		}
		
		public function removeHashKey(objType:String, key:String, callback:Function=null):RemoveHashKeyDelegate
		{
			var delegate:RemoveHashKeyDelegate = new RemoveHashKeyDelegate(facebook, objType, key);
			return MethodGroupUtil.addCallback(delegate, callback) as RemoveHashKeyDelegate;
		}
		
		public function removeHashKeys(objType:String, keys:Array, callback:Function=null):RemoveHashKeysDelegate
		{
			var delegate:RemoveHashKeysDelegate = new RemoveHashKeysDelegate(facebook, objType, keys);
			return MethodGroupUtil.addCallback(delegate, callback) as RemoveHashKeysDelegate;
		}
		
		
		// Association Data Definition API //////////
		
		
		
		// Association Data Access API //////////
		
		
	}
}